package com.ruoyi.mng.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mng.domain.HzCardOrder;
import com.ruoyi.mng.service.IHzCardOrderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卡风险状态验证订单Controller
 * 
 * @author Qiang
 * @date 2023-04-23
 */
@Controller
@RequestMapping("/mng/cardorder")
public class HzCardOrderController extends BaseController
{
    private String prefix = "mng/cardorder";

    @Autowired
    private IHzCardOrderService hzCardOrderService;

    @RequiresPermissions("mng:cardorder:view")
    @GetMapping()
    public String cardorder()
    {
        return prefix + "/cardorder";
    }

    /**
     * 查询卡风险状态验证订单列表
     */
    @RequiresPermissions("mng:cardorder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HzCardOrder hzCardOrder)
    {
        startPage();
        List<HzCardOrder> list = hzCardOrderService.selectHzCardOrderList(hzCardOrder);
        return getDataTable(list);
    }

    /**
     * 导出卡风险状态验证订单列表
     */
    @RequiresPermissions("mng:cardorder:export")
    @Log(title = "卡风险状态验证订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HzCardOrder hzCardOrder)
    {
        List<HzCardOrder> list = hzCardOrderService.selectHzCardOrderList(hzCardOrder);
        ExcelUtil<HzCardOrder> util = new ExcelUtil<HzCardOrder>(HzCardOrder.class);
        return util.exportExcel(list, "卡风险状态验证订单数据");
    }

    /**
     * 新增卡风险状态验证订单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存卡风险状态验证订单
     */
    @RequiresPermissions("mng:cardorder:add")
    @Log(title = "卡风险状态验证订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HzCardOrder hzCardOrder)
    {
        return toAjax(hzCardOrderService.insertHzCardOrder(hzCardOrder));
    }

    /**
     * 修改卡风险状态验证订单
     */
    @RequiresPermissions("mng:cardorder:edit")
    @GetMapping("/edit/{orderId}")
    public String edit(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
        HzCardOrder hzCardOrder = hzCardOrderService.selectHzCardOrderByOrderId(orderId);
        mmap.put("hzCardOrder", hzCardOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存卡风险状态验证订单
     */
    @RequiresPermissions("mng:cardorder:edit")
    @Log(title = "卡风险状态验证订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HzCardOrder hzCardOrder)
    {
        return toAjax(hzCardOrderService.updateHzCardOrder(hzCardOrder));
    }

    /**
     * 删除卡风险状态验证订单
     */
    @RequiresPermissions("mng:cardorder:remove")
    @Log(title = "卡风险状态验证订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(hzCardOrderService.deleteHzCardOrderByOrderIds(ids));
    }

    /**
     * 查看卡风险状态验证订单
     */
    @RequiresPermissions("mng:cardorder:list")
    @GetMapping("/detail/{orderId}")
    public String detail(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
        HzCardOrder hzCardOrder = hzCardOrderService.selectHzCardOrderByOrderId(orderId);
        mmap.put("hzCardOrder", hzCardOrder);
        return prefix + "/detail";
    }
}
